const TOKEN_KEY = 'user_token_key'
export function saveToken(token) {
	uni.setStorageSync(TOKEN_KEY, token)
}

export function removeToken() {
	uni.removeStorageSync(TOKEN_KEY)
}

export function getToken() {
	try {
		return uni.getStorageSync(TOKEN_KEY) 
	} catch (e) {}
	return null
}

const PWD_KEY = 'PWD_KEY'

export function savePwd(token) {
	uni.setStorage({
		key: PWD_KEY,
		data: token,
		success: function () {
			// console.log('success');
		}
	})
}

export function removePwd() {
	uni.removeStorage({
		key: PWD_KEY,
		success: function (res) {}
	})
}

export function getPwd() {
	try {
		return uni.getStorageSync(PWD_KEY) 
	} catch (e) {
	}
	return null
}

const STREAM_KEY = 'STREAM_KEY'

export function saveStream(val) {
	uni.setStorage({
		key: STREAM_KEY,
		data: val,
		success: function () {
			// console.log('success');
		}
	})
}

export function getStream() {
	try {
		let flag = uni.getStorageSync(STREAM_KEY)
		if (flag === '') {
			flag = true
		}
		return flag
	} catch (e) {
	}
	return null
}

const CHAT_TYPE_KEY = 'CHAT_TYPE_KEY'
export function saveChatType(val) {
	uni.setStorage({
		key: CHAT_TYPE_KEY,
		data: val,
		success: function () {
			// console.log('success');
		}
	})
}

export function getChatType() {
	try {
		return uni.getStorageSync(CHAT_TYPE_KEY)
	} catch (e) {
	}
	return null
}
